/**
 * Created with JetBrains PhpStorm.
 * User: Administrator
 * Date: 13-8-30
 * Time: 下午12:13
 * To change this template use File | Settings | File Templates.
 */
function sub(str,data) {
    return str
        .replace(/{(.*?)}/igm,function($,$1) {
            return data[$1]?data[$1]:$;
        });
}
jQuery(document).ready(function($){
    var tickts = '',
        tpl = '<tr> ' +
            '<td>{ticketTitle}</td>'+
            '<td>{marketPrice}</td>' +
            '<td>{salePrice}</td> ' +
            '<td><span class="money">{setlPrice}</span></td> ' +
            '<td>{validDays}</td>' +
            '<td>{num}</td>' +
            '<td>{preOrderDays}</td>' +
            '<td><a href="productOrder.html?pid={prodid}" class="prodbtn"><span>预订</span></a></td>' +
            '</tr>';
    $.getJSON('call/jh_prod.php',{action:'GetTickets',lid:$("input#landid").val()})
        .done(function(res){
            var i= 0,len = res.length;
            if(!len) {
                tickts = '<tr><td colspan="8">抱歉，该产品暂无票价信息！</td></tr>';
            }
            else{
                for(;i<len;i++) {
                    tickts += sub(tpl, res[i]);
                }
                tickts += '<tr><td colspan="8" class="explain">备注：具体价格以预定日期当天为准。</td></tr>'
            }
            $("tbody#ticketList").empty().html(tickts);
        });
});